//
//  WelcomeViewController.swift
//  LCYWeiBo
//
//  Created by 李长友 on 16/9/5.
//  Copyright © 2016年 app. All rights reserved.
//

import UIKit
import SDWebImage

class WelcomeViewController: UIViewController {

    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var topConstraint: NSLayoutConstraint!
    @IBOutlet weak var welcomeLabel: UILabel!
    override func viewDidLoad() {
        super.viewDidLoad()
        
        iconImageView.sd_setImageWithURL(NSURL(string: (UserViewModel.shareInstance.user?.avatar_large) ?? ""), placeholderImage: UIImage(named: "avatar_default"))
        
        iconImageView.layer.cornerRadius = iconImageView.frame.size.width / 2
        iconImageView.layer.masksToBounds = true
        
        topConstraint.constant = 100
        
        UIView.animateWithDuration(1.0, delay: 0.0, usingSpringWithDamping: 0.6, initialSpringVelocity: 5.0, options: [], animations: {
            self.view.layoutIfNeeded()
            }) { (_) in
                UIView.animateWithDuration(1.0, animations: { 
                    self.welcomeLabel.alpha = 1.0
                    }, completion: { (_) in
                        UIApplication.sharedApplication().keyWindow?.rootViewController = MainViewController()
                })
        }
    }
}
